Title
import re
import pandas as pd
import seaborn as sns
sns.set()
import plotly.express as px
import plotly.graph_objects as go
df = pd.read_csv("indicators.csv.gz")
df.head()
rpd_outliers = "indicator == 'rpd' and 0 <= value <= 0.4"
eps_outliers = "indicator == 'eps' and 0 <= value <= 4"
igd_outliers = "indicator == 'igd' and 0 <= value <= 10"
df_no_moga = df.query("algo != 'moga'")
df_no_moga_nor_outliers = df_no_moga.query(f"{rpd_outliers} or {eps_outliers} or {igd_outliers}")
df_tuned_default = df_no_moga_nor_outliers.pivot_table(
index=["FE", "algo", "indicator", "nobj", "problem", "nvar"],
columns=["setup"],
values=["value"]
)
df_tuned_default = df_tuned_default.droplevel(0, axis=1).reset_index()
df_tuned_default
def add_line(fig, xmax, col):
fig.add_scatter(
x=[0, xmax],
y=[0, xmax],
mode="lines",
line=go.scatter.Line(color="red"),
row=1,
col=col,
showlegend=False,
)
fig = px.scatter(
df_tuned_default,
x="tuned",
y="default",
facet_col="indicator",
category_orders={"indicator": ["rpd", "eps", "igd"]},
height=400,
)
for k in fig.layout:
if re.search('xaxis[1-9]+', k):
fig.layout[k].update(matches=None)
for k in fig.layout:
if re.search('yaxis[1-9]+', k):
fig.layout[k].update(matches=None)
add_line(fig, 0.4, 1)
add_line(fig, 4, 2)
add_line(fig, 10, 3)
fig
df_anytime = pd.read_csv("anytime.csv.gz")
df_anytime["config"] = df_anytime["config"].fillna("default")
df_anytime
df_anytime_mean = df_anytime.groupby(["setup", "config", "algo", "indicator", "nobj", "problem", "nvar"]).mean()
df_anytime_mean = df_anytime_mean.drop(columns=["seed"])
ts_anytime = df_anytime_mean.stack().reset_index(
["setup", "config", "algo", "indicator", "nobj", "problem", "nvar"],
name="value"
)
ts_anytime.index = ts_anytime.index.astype("int")
ts_anytime
ts_ibea_WFG8_3_30 = ts_anytime.query("algo == 'ibea' and problem == 'WFG8' and nobj == 3 and nvar == 30")\
.sort_index()
fig2 = px.line(
ts_ibea_WFG8_3_30,
y="value",
x=ts_ibea_WFG8_3_30.index,
color="config",
line_dash="config",
)
fig2.show()
ts_ibea = ts_anytime.query("algo == 'ibea'")
fig2_full = px.line(
ts_ibea,
y="value",
x=ts_ibea.index,
color="config",
line_dash="config",
animation_frame="nvar",
facet_col="problem",
facet_col_wrap=3,
height=1500,
)
fig2_full.show()
df_ibea_snapshots = ts_ibea.loc[[2500,10000,40000]].reset_index().rename(columns={"index": "FE"})
rs_ibea_snapshots = df_ibea_snapshots.drop(columns=["setup", "algo", "indicator"])\
.pivot_table(index=["problem", "nobj", "nvar", "FE"], columns=["config"])\
.rank(axis=1).groupby("FE").sum()
for FE in [2500, 10000, 40000]:
rs_ibea_diff = (rs_ibea_snapshots.loc[FE] - rs_ibea_snapshots.loc[FE].min())
display(rs_ibea_diff.sort_values().to_frame().T)
ts_10k_WFG3_3_50 = ts_anytime.query("config == 10000 and problem == 'WFG3' and nobj == 3 and nvar == 50")\
.sort_index()
fig4 = px.line(
ts_10k_WFG3_3_50,
y="value",
x=ts_10k_WFG3_3_50.index,
color="algo",
line_dash="algo",
)
fig4.show()
ts_10k = ts_anytime.query("config == 10000")
fig4_full = px.line(
ts_10k,
y="value",
x=ts_10k.index,
color="algo",
line_dash="algo",
animation_frame="nvar",
facet_col="problem",
facet_col_wrap=3,
height=1500,
)
for k in fig4_full.layout:
if re.search('yaxis[1-9]+', k):
fig4_full.layout[k].update(matches=None)
fig4_full.show()
algo_fig5 = ["ibea", "sms"]
ind_fig5 = ["rpd", "igd"]
scenario_fig5 = "problem == 'WFG8' and nobj == 2 and nvar == 30 and FE == 10000"
df_fig5 = df.query(f"algo in {algo_fig5} and indicator in {ind_fig5} and {scenario_fig5} and setup == 'tuned'")
fig5 = px.box(
df_fig5,
y="algo",
x="value",
color="algo",
facet_col="indicator",
height=300,
width=600,
)
fig5.show()
df_tuned_no_outliers = df.query(f"setup == 'tuned' and {rpd_outliers} or {eps_outliers} or {igd_outliers}")
fig5_full = px.box(
df_tuned_no_outliers,
x="nvar",
y="value",
color="algo",
facet_col="nobj",
facet_row="problem",
animation_frame="indicator",
height=4000,
category_orders={"indicator": ["rpd", "eps", "igd"]}
# width=600,
)
# for k in fig5_full.layout:
# if re.search('yaxis[1-9]+', k):
# fig5_full.layout[k].update(matches=None)
fig5_full.show()